﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using StuWebApi.Dto;
using StuWebApi.Entity;

namespace StuWebApi.Controllers;

[ApiController]
[Route("[controller]")]
public class LogsController : ControllerBase
{
    private readonly ApplicationDbContext _context;

    public LogsController(ApplicationDbContext context)
    {
        _context = context;
    }

    [HttpGet]
    public async Task<ActionResult<IEnumerable<Log>>> GetLogs()
    {
        return await _context.Logs.OrderByDescending(l => l.Timestamp).ToListAsync();
    }
}
